﻿using Abp.Application.Navigation;
using Abp.Localization;
using DualControl.Authorization;

namespace DualControl.Web.Startup
{
    /// <summary>
    /// This class defines menus for the application.
    /// </summary>
    public class DualControlNavigationProvider : NavigationProvider
    {
        public override void SetNavigation(INavigationProviderContext context)
        {
            context.Manager.MainMenu
                .AddItem(
                    new MenuItemDefinition(
                        PageNames.Home,
                        L("HomePage"),
                        url: "",
                        icon: "home",
                        requiresAuthentication: true
                    )
                ).AddItem(
                    new MenuItemDefinition(
                        PageNames.CompanyInfo,
                        L("CompanyInfo"),
                        url: "CompanyInfo",
                        icon: "business",
                        requiresAuthentication: true
                    )
                )

                .AddItem(
                    new MenuItemDefinition(
                        PageNames.Tenants,
                        L("Tenants"),
                        url: "Tenants",
                        icon: "business",
                        requiredPermissionName: PermissionNames.Pages_Tenants
                    )
                )
                .AddItem(
                    new MenuItemDefinition(
                        PageNames.Roles,
                        L("Roles"),
                        url: "Roles",
                        icon: "local_offer",
                        requiredPermissionName: PermissionNames.Pages_Roles
                    )
                )
                .AddItem(
                    new MenuItemDefinition(
                        PageNames.Organizations,
                        L("OrganizationUnits"),
                        url: "Organizations",
                        icon: "people",
                        requiredPermissionName: PermissionNames.Pages_OrganizationUnits
                    )
                ).AddItem(
                    new MenuItemDefinition(
                        PageNames.Posts,
                        L("Posts"),
                        url: "Posts",
                        icon: "people",
                        requiredPermissionName: PermissionNames.Pages_Users
                    )
                ).AddItem( // 折叠菜单  员工管理
                    new MenuItemDefinition(
                        "Users",
                        L("Users"),
                        icon: "menu"
                        )
                        .AddItem(
                        new MenuItemDefinition(
                        PageNames.Users, L("UserInfo"),
                        url: "Users", icon: "info",
                        requiredPermissionName: PermissionNames.Pages_Users
                    )
                    ).AddItem(
                        new MenuItemDefinition(
                        PageNames.Users, L("UserPost"),
                        url: "Users/UserPostAndOrg", icon: "info",
                        requiredPermissionName: PermissionNames.Pages_Users
                    )
                    )
                ).AddItem( // 折叠菜单  风险识别
                    new MenuItemDefinition(
                        "RiskIdentification",
                        L("RiskIdentification"),
                        icon: "menu"
                        )
                        .AddItem(
                        new MenuItemDefinition(
                        PageNames.RiskPoint, L("RiskPoint"),
                        url: "RiskPoint", icon: "warning",
                        requiredPermissionName: PermissionNames.Pages_RiskPoint
                    )
                    ).AddItem(
                        new MenuItemDefinition(
                        PageNames.RiskPoint, L("HazardSource"),
                        url: "HazardSource", icon: "warning",
                        requiredPermissionName: PermissionNames.Pages_HazardSource
                    )
                    ).AddItem(
                        new MenuItemDefinition(
                        PageNames.RiskPoint, L("RiskFactor"),
                        url: "RiskFactor", icon: "warning",
                        requiredPermissionName: PermissionNames.Pages_HazardSource
                    )
                    )
                ).AddItem( // 折叠菜单  风险评估管控
                    new MenuItemDefinition(
                        "RiskEvaluationControl",
                        L("RiskEvaluationControl"),
                        icon: "menu"
                        )
                        .AddItem(
                        new MenuItemDefinition(
                        PageNames.About, L("RiskFactorEvaluation"),
                        url: "HazardSource?view=RiskFactorEvaluation", icon: "edit",
                        requiredPermissionName: PermissionNames.Pages_HazardSource
                    )
                    ).AddItem(
                        new MenuItemDefinition(
                        PageNames.About, L("RiskControl"),
                        url: "HazardSource?view=RiskControl", icon: "edit",
                        requiredPermissionName: PermissionNames.Pages_HazardSource
                    )
                    ).AddItem(
                        new MenuItemDefinition(
                        PageNames.About, L("ControlMeasure"),
                        url: "ControlMeasure", icon: "edit",
                        requiredPermissionName: PermissionNames.Pages_HazardSource
                    )
                    ).AddItem(
                        new MenuItemDefinition(
                        PageNames.About, L("EmergencyMeasure"),
                        url: "EmergencyMeasures", icon: "edit",
                        requiredPermissionName: PermissionNames.Pages_HazardSource
                    )
                    ).AddItem(
                        new MenuItemDefinition(
                        PageNames.About, L("HiddenTroubleCriteria"),
                        url: "ControlMeasure/HTCriteria", icon: "edit",
                        requiredPermissionName: PermissionNames.Pages_HazardSource
                    )
                    )

                ).AddItem( // 折叠菜单  风险库
                    new MenuItemDefinition(
                        "RiskLibrary",
                        L("RiskLibrary"),
                        icon: "menu"
                        ).AddItem(
                        new MenuItemDefinition(
                        PageNames.About, L("RiskPointNotification"),
                        url: "RiskNotification", icon: "info",
                        requiredPermissionName: PermissionNames.Pages_RiskPoint
                    )
                    )
                )

                .AddItem( // 折叠菜单  隐患排查治理
                    new MenuItemDefinition(
                        "隐患排查治理",
                        L("InvestigationManagement"),
                        icon: "menu"
                  ).AddItem(
                        new MenuItemDefinition(
                        PageNames.About, L("HiddenTroubleInvestigation"),
                        url: "CycleCheckTask", icon: "edit",
                        requiredPermissionName: PermissionNames.Pages_HazardSource
                    )
                  ).AddItem(
                        new MenuItemDefinition(
                        PageNames.About, L("HiddenTroubleManagement"),
                        url: "HazardSource?view=RiskControl", icon: "edit",
                        requiredPermissionName: PermissionNames.Pages_HazardSource
                    )
                    ).AddItem(
                        new MenuItemDefinition(
                        PageNames.About, L("CorrectiveFeedback"),
                        url: "ControlMeasure", icon: "edit",
                        requiredPermissionName: PermissionNames.Pages_HazardSource
                    )
                    ).AddItem(
                        new MenuItemDefinition(
                        PageNames.About, L("Acceptance"),
                        url: "ControlMeasure", icon: "edit",
                        requiredPermissionName: PermissionNames.Pages_HazardSource
                    )
                    )
                )
                .AddItem(
                    new MenuItemDefinition(
                        PageNames.About,
                        L("About"),
                        url: "About",
                        icon: "info"
                    )
                )          
            ;
        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, DualControlConsts.LocalizationSourceName);
        }
    }
}
